package com.wentao.thisCommon.model;


import com.wentao.thisCommon.common.EnumsBase;
import com.wentao.thisCommon.common.ResultBaseInterface;

public class ResultBase<T> implements ResultBaseInterface {
    private T body;
    private String resultCode;
    private String message;

    public ResultBase(){

    }

    public ResultBase(T obj, String msg, String code){
        this.body = obj;
        this.message = msg;
        this.resultCode = code;
    }

    public static ResultBase ok(EnumsBase enumsBase){
        ResultBase resultBase = new ResultBase();
        resultBase.setMessage(enumsBase.getMessage());
        resultBase.setResultCode(enumsBase.getCode());
        return resultBase;
    }

    public static ResultBase ok(Object body,EnumsBase enumsBase){
        ResultBase resultBase = new ResultBase();
        resultBase.setMessage(enumsBase.getMessage());
        resultBase.setResultCode(enumsBase.getCode());
        resultBase.setBody(body);
        return resultBase;
    }

    public String getResultCode() {
        return resultCode;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getBody() {
        return body;
    }

    public void setBody(T body) {
        this.body = body;
    }


    @Override
    public void addBody(Object body) {
        this.body = (T)body;
    }

    @Override
    public void addResultCode(String code) {
        this.resultCode = code;
    }

    @Override
    public void addResultMessage(String msg) {
        this.message = msg;
    }
}
